package com.sc.nft.entity.vo;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class UserConsignEquityPropsPageVO {

    @ApiModelProperty(name = "权益道具id")
    private Long equityPropsId;

    @ApiModelProperty(name = "用户权益道具id")
    private Long userEquityPropsId;

    @ApiModelProperty(name = "买入价")
    private String buyPrice;

    @ApiModelProperty(name = "创建时间戳")
    private Long createTimeStamp;

    @ApiModelProperty(name = "当前时间戳")
    private Long nowTimeStamp;

    @ApiModelProperty(name = "过期时间戳")
    private Long expiredTimeStamp;

    @ApiModelProperty(name = "剩余时间戳")
    private Long residualTimeStamp;

    @ApiModelProperty(name = "剩余天数 大于等于365则长期有效")
    private Long residualDay;

    @ApiModelProperty(name = "是否可寄售")
    private Boolean isConsign;

    public void setBuyPrice(BigDecimal buyPrice) {
        this.buyPrice = buyPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setExpiredTimeStamp(Long expiredTimeStamp) {
        this.expiredTimeStamp = expiredTimeStamp;
        this.residualTimeStamp = expiredTimeStamp - this.nowTimeStamp ;
        this.residualDay =  residualTimeStamp / (24*60*60);
        this.isConsign = this.residualDay >= 365 ? Boolean.TRUE : Boolean.FALSE;
    }


}
